package com.demo.juc.future.completableFuture;

import java.util.concurrent.CompletableFuture;

/**
 * @Author: jxm
 * @Description:
 * @Date: 2023/5/24 16:21
 * @Version: 1.0
 */
public class Dmo1 {

    public static void main(String[] args) {
//        CompletableFuture<Integer> future1
//                = CompletableFuture.supplyAsync(()->{
//            System.out.println("compute 1");
//            return 1;
//        });
//        CompletableFuture<Integer> future2
//                = future1.thenApply((p)->{
//            System.out.println("compute 2");
//            return p+10;
//        });
        CompletableFuture<Integer> future1
                = CompletableFuture.supplyAsync(()->{
            System.out.println("compute 1");
            return 1;
        }).thenApply((p)->{
            System.out.println("compute 2");
            return p+10;
        });

        System.out.println("result: " + future1.join());


    }
}
